<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\Database\Model\Events\Created;

/**
 * @property int $id 
 * @property string $name 分类名
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 修改时间
 * @property string $deleted_at 删除时间（不会有）
 * @property string $extend 扩展字段 以防万一
 * @property int $shop_id 商户id
 * @property int is_init 1初始化默认分类
 */
class FlyGourmetMealClassify extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'fly_gourmet_meal_classify';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['id', 'name', 'created_at', 'updated_at', 'deleted_at', 'extend', 'shop_id'];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'shop_id' => 'integer'];

//    已审核产品列表
    public function product_list()
    {
        return $this->hasMany(Product::class,'category_id','id')
            ->with(['shop_info', 'cate_info', 'sku_list'])
            ->with(['reason_info', 'refuse_info', 'main_pic','file_info'])
            ->where('fly_product.is_illegal','0')
            ->where('fly_product.is_show','1')
            ->where('fly_product.check_status','1');
    }
}